<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>审批历史明细</title>
    <#include "/pubHeadStyle.html">
</head>
<body>
<span>流程实例-【<i>${processRun.subject}</i>】审批历史明细</span>
<div class="ccpui-tablesize opinion" style="margin-top: 15px;">
    <table class="layui-hide" id="opinionTable" lay-filter="opinionTable"></table>
</div>
<div id="opinionTable2" style="display: none"></div>
<div class="layui-btn-container" style="width:100%;position: absolute;bottom: 20px;text-align: center;">
    <button class="layui-btn layui-btn-danger" id="close" style="margin: 0!important;">关闭</button>
</div>
<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','table','util','setter'], function () {
        var table = layui.table
            ,util = layui.util
            ,setter  = layui.setter
            ,$=layui.$;
        $(".opinion").height($(".layui-layout-body").height()-100);
        $(".opinion").css("overflow","auto");
        if ($(".layui-tab-title").length>0){
            $("#close").hide();
        }
        table.render({
            elem: '#opinionTable'
            , title: ''
            , url: serverPath.workflowPath + setter.workflowLinkPath + 'taskOpinion/list?runId=${processRun.runId}'
            , method: 'post'
            , page: false
            , cols: [[
                {field: 'taskName', title: '任务节点', align: 'center'}
                , {field: 'startTime', title: '开始时间', align: 'center',templet: function (d) {
                        if (d.startTime!=undefined && d.startTime!=null) {
                            return util.toDateString(d.startTime, "yyyy-MM-dd HH:mm:ss");
                        }else{
                            return "";
                        }
                    }}
                , {field: 'endTime', title: '结束时间', align: 'center',templet: function (d) {
                        if (d.endTime != undefined && d.endTime!=null) {
                            return util.toDateString(d.endTime, "yyyy-MM-dd HH:mm:ss");
                        }else{
                            return "";
                        }
                    }}
                , {field: 'durTime', title: '经历时间', align: 'center',templet: function (d) {
                        if (d.durTime!=undefined && d.durTime!=null) {
                            var minute = Math.floor(d.durTime/(60*1000));
                            var duration = minute+"分钟";
                            return duration;
                        }else{
                            return "";
                        }
                    }}
                , {field: 'exeFullname', title: '执行人', align: 'center',event:'userCc',templet: function (d) {
                        if(d.exeUserId!="" && d.exeFullname!=""){
                            return "<a onclick=authUserClick('"+d.exeUserId+"') href='javascript:void(0);' style='color: blue;margin-right: 5px;'>"+d.exeFullname+"</a>";
                        }else{
                            var candidateUserHtml="";
                            for(var i=0;i<d.candidateUsers.length;i++){
                                candidateUserHtml+="<a onclick=authUserClick('"+d.candidateUsers[i].userId+"') href='javascript:void(0);' style='color: blue;margin-right: 5px;'>"+d.candidateUsers[i].fullName+"</a>";
                            }
                            return candidateUserHtml;
                        }
                    }}
                , {field: 'opinion', title: '审批意见', align: 'center'}
                , {field: 'attachment', title: '附件',templet: function (d) {
                        if(d.attachment!=""){
                            var json = JSON.parse(d.attachment);
                            var html="";
                            for(var i=0;i<json.length;i++){
                                var obj = json[i];
                                html+="<a onclick=\"downloadFile('"+obj.id+"')\" href=\"javascript:void(0);\" style=\"color: blue;margin-right: 5px;\">"+obj.name+"</a>";
                            }
                            return html;
                        }else{
                            return "";
                        }
                    }}
                , {field: 'checkStatus', title: '审批状态', align: 'center',templet: function (d) {
                        if(d.checkStatus!=""){
                            return getTaskStatus(d.checkStatus,0);
                        }
                    }}
            ]]


        });

        downloadFile = function(fileId){
            window.open(serverPath.systemPath + setter.sysLinkPath + "attachFile/download?fileId="+fileId,'_blank');
        };
        // 点击授权人员弹窗
        authUserClick = function(ownerId){
            var src =  serverPath.systemPath + setter.sysLinkPath + 'sysUser/view/view?userId=' +  ownerId;
            parent.layer.open({
                type: 2,
                title: "人员详细信息",
                shade: 0.3,
                area: ['938px', '620px'],
                content: src,
                zIndex: layer.zIndex
            });
        };
        function getTaskStatus(status,flag){
            switch (status) {
                case -2://尚未审批
                    return "<span class='red'>尚未审批</span>";
                case -1://尚未处理(0) || 正在审批(1)
                    return flag==0?"尚未处理":"<span color='red'>正在审批</span>";
                case 0://弃权
                    return "<span class='red'>弃权</span>";
                case 1://同意
                    return "<span class='green'>同意</span>";
                case 2://反对
                    return "<span class='orange'>反对</span>";
                case 3://驳回
                    return "<span class='red'>驳回</span>";
                case 4://撤销
                    return "<span class='red'>撤销</span>";
                case 5://会签通过
                    return "<span class='green'>会签通过</span>";
                case 6://会签不通过
                    return "<span class='red'>会签不通过</span>";
                case 7://知会意见
                    return "<span class='red'>知会意见</span>";
                case 8://更改执行路径
                    return "<span class='red'>更改执行路径</span>";
                case 9://终止
                    return "<span class='red'>终止</span>";
                case 10://沟通意见
                    return "<span class='red'>沟通意见</span>";
                case 14://终止
                    return "<span class='red'>终止</span>";
                case 15://沟通
                    return "<span class='red'>沟通 </span>";
                case 16://办结转发
                    return "<span class='orange'>办结转发</span>";
                case 17://撤销
                    return "<span class='orange'>撤销</span>";
                case 18://删除
                    return "<span class='orange'>删除</span>";
                case 19://抄送
                    return "<span class='orange'>抄送</span>";
                case 20://沟通反馈
                    return "<span class='green'>沟通反馈</span>";
                case 21://转办
                    return "<span class='red'>转办</span>";
                case 22://取消转办
                    return "<span class='red'>取消转办</span>";
                case 23://更改执行人
                    return "<span class='red'>更改执行人</span>";
                case 24://驳回到发起人
                    return "<span class='red'>驳回到发起人</span>";
                case 25://撤销(撤销到发起人)
                    return "<span class='red'>撤销(撤销到发起人)</span>";
                case 26://代理
                    return "<span class='brown'>代理</span>";
                case 27://取消代理
                    return "<span class='green'>取消代理</span>";
                case 28://表单意见
                    return "<span class='green'>表单意见</span>";
                case 29://表单意见
                    return "<span class='green'>驳回取消</span>";
                case 30://撤销取消
                    return "<span class='brown'>撤销取消</span>";
                case 31://通过取消
                    return "<span class='brown'>通过取消</span>";
                case 32://反对取消
                    return "<span class='brown'>反对取消</span>";
                case 33://提交
                    return "<span class='green'>提交</span>";
                case 34://重新提交
                    return "<span class='green'>重新提交</span>";
                case 35://干预
                    return "<span class='brown'>干预</span>";
                case 36://重启任务
                    return "<span class='brown'>重启任务</span>";
                case 38://流转
                    return "<span class='green'>流转</span>";
                case 40://代提交
                    return "<span class='red'>代提交</span>";
                case 42://取消流转
                    return "<span class='red'>取消流转</span>";
                case 43://添加流转人
                    return "<span class='red'>添加流转人</span>";
                case 44://补签
                    return "<span class='red'>补签</span>";
                case 45://追回
                    return "<span class='red'>追回</span>";
                case 46://追回
                    return "<span class='brown'>任务交接</span>";
                default:
                    break;
            }
            return "";
        }
        $('#close').click(function () {
            var index=parent.layer.getFrameIndex(window.name);
            if(index) {
                parent.layer.close(index);
            }else {
                //关闭流程明细之审批历史的网页
                window.parent.opener = null;
                window.parent.open('', '_self');
                window.parent.close();
            }
        })
    });
</script>

<style>
    span.red {
        color:red;
    }
    span.green {
        color:green;
    }
    span.orange {
        color:orange;
    }
    span.brown {
        color:brown;
    }
</style>
</body>
</html>